<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>编写四则运算</title>
		<script>
			<!--
			function operation() {
				var count;
				var num1 = window.prompt("请输入第一个数：");
				var reg = /^[0-9]+.?[0-9]*$/;
				if (!reg.test(num1)) {
					window.alert("请检查后重新输入！");
				}
				var num2 = window.prompt("请输入第二个数：");
				if (!reg.test(num2)) {
					window.alert("请检查后重新输入！");
				}
				var symbol = window.prompt("请输入运算符号：");
				if (symbol == '+') {
					count = parseInt(num1) + parseInt(num2);
				} else if (symbol == '-') {
					count = parseInt(num1) - parseInt(num2);
				} else if (symbol == '*') {
					count = parseInt(num1) * parseInt(num2);
				} else if (symbol == '/') {
					count = parseInt(num1) / parseInt(num2);
				}
				window.alert("两数运算结果为：" + num1 + symbol + num2 + '=' + count);
			}
			-->
		</script>
	</head>
	<body>
		<input type="button" value="计算两数运算结果" onclick="operation()" />
	</body>
</html>
